#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "driver/gpio.h"
#include "esp_log.h"
#include "led_strip.h"
#include "sdkconfig.h"
#include "esp_random.h"
#include "ws2812B.h"

static const char *TAG = "APP_RGB";


static bool s_led_state = true;

void blink_led(void *pvParameters) 
{
    while (1)
    {
        if (s_led_state && led_strip) {
            uint8_t red = esp_random() % 256;
            uint8_t green = esp_random() % 256;
            uint8_t blue = esp_random() % 256;
            led_strip_set_pixel(led_strip, 0, red, green, blue);
            led_strip_refresh(led_strip);
            ESP_LOGI(TAG,"blink_led set color");
        } else if (led_strip) {
            led_strip_clear(led_strip);
            ESP_LOGI(TAG,"blink_led set off");
        }
        ESP_LOGI(TAG,"blink_led running");
        vTaskDelay(pdMS_TO_TICKS(1000));
    }
}